package com.BUG001;

import java.io.FilePermission;
import java.security.AccessController;
import java.security.Permission;

public class FileAccessDemo {

    public static void main(String[] args) {
        // 要检查的路径
        String path = "D:\\tmp\\upload";

        // 创建一个FilePermission对象来表示对指定路径的写权限
        Permission permission = new FilePermission(path, "write");

        // 检查当前安全管理器是否允许访问该路径的写权限
        try {
            AccessController.checkPermission(permission);
            System.out.println("具有对路径 " + path + " 的写权限");
        } catch (SecurityException e) {
            System.out.println("没有对路径 " + path + " 的写权限");
        }
    }
}